import Mock from 'mockjs'

Mock.setup({
  timeout: '300 - 500'
})
// 自动引入mock文件
let configArray = []
const files = require.context('./data/', true, /\.js$/)
files.keys().forEach((key) => {
  configArray = configArray.concat(files(key).default)
})

// 注册所有的mock服务
configArray.forEach((item) => {
  for (let [path, target] of Object.entries(item)) {
    let protocol = path.split('|')
    Mock.mock(new RegExp('^' + protocol[1]), protocol[0], target)
  }
})
